package com.eben.model;

import com.eben.utils.StopWatch;

/**
 * This class purpose is to keep track of how long the game has been running.
 * @author Sebbe
 */

public class Time {
	private StopWatch stopwatch;
	
	/**
	 * Creates a new time object.
	 */
	public Time(){
		stopwatch = new StopWatch();	
		}
	
	/**
	 * Returns the time (in seconds) elapsed since the Time was started.
	 * @return the elapsed time in seconds. Returns 0 if the timers is not started.
	 */
	public double getTime() {
		return (double)stopwatch.getElapsedTime()/1000;
	}

	/**
	 * Starts the time. Can be used to reset the time instead of creating a new time object.
	 */
	public void startTime(){
		stopwatch.start();
	}
	
	/**
	 * Stops the time.
	 */
	public void stopTime(){
		stopwatch.stop();
	}
	
	/**
	 * Sets the time to 0 but still counting.
	 */
	public void resetTime(){
		stopwatch.stop();
		stopwatch.start();
	}

}
